//
//  BaseSettingCell.m
//  GIFShow
//
//  Created by lanou11air029 on 15/4/12.
//  Copyright (c) 2015年 CK. All rights reserved.
//

#import "BaseSettingCell.h"

@interface BaseSettingCell ()
@end
@implementation BaseSettingCell

-(void)prepareForReuse{
    self.rightDetailLabel.text = @"";
    self.imageTitleView.image = nil;
    [super prepareForReuse];
}

- (void)awakeFromNib {
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupSubviews];
    }
    return self;
}

-(void)setupSubviews{
    CGRect screenBounds = [UIScreen mainScreen].bounds;
    //    CGFloat orignY = screenBounds.size.height * 0.09;
    //    CGFloat btnWidth = screenBounds.size.width * 0.25;
    //    CGFloat btnHeight = screenBounds.size.height * 0.25;
    self.imageTitleView = [[UIImageView alloc]initWithFrame:CGRectMake(15, screenBounds.size.height * 0.005, screenBounds.size.height * 0.075, screenBounds.size.height * 0.075)];
    [self.contentView addSubview:self.imageTitleView];
    self.textTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.imageTitleView.frame.size.width+15, 0, 100, screenBounds.size.height * 0.085)];
    self.textTitleLabel.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:self.textTitleLabel];
    self.rightDetailLabel = [[UILabel alloc]initWithFrame:CGRectMake(screenBounds.size.width - 100, 0, 100, screenBounds.size.height*0.085)];
    self.rightDetailLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:self.rightDetailLabel];

}
-(void)setTitle:(NSString *)title{
    if (_title != title) {
        _title = title;
        self.textTitleLabel.text = _title;
    }
}

-(void)layoutSubviews{
    [super layoutSubviews];
    [self.textTitleLabel sizeToFit];
    [self.rightDetailLabel sizeToFit];
    CGRect cellFrame = self.textTitleLabel.frame;
    cellFrame.size.height = [UIScreen mainScreen].bounds.size.height*0.085;
    self.textTitleLabel.frame = cellFrame;
    
    CGRect imageFrame = self.imageTitleView.frame;
    imageFrame.size.height = [UIScreen mainScreen].bounds.size.height*0.075;
    self.imageTitleView.frame = imageFrame;
    
    CGRect rightFrame = self.rightDetailLabel.frame;
    rightFrame.origin.x = [UIScreen mainScreen].bounds.size.width - self.rightDetailLabel.frame.size.width - 15;
    rightFrame.size.height = [UIScreen mainScreen].bounds.size.height*0.085;
    self.rightDetailLabel.frame = rightFrame;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
